from sys import exit
from os import listdir

class Analyzer:
    def __init__(self,mode):
        self.f = None
        self.data = None
                
        
        if mode in ['uni','duo','tri','word']:
            self.mode = mode
        else:
            print '[WARNING] Invalid Mode, defaulting to uni'
            self.mode = 'uni'
    
    def GiveFile(self,f):
        try:
            if f.mode != 'r':
                raise 'InvalidMode'
        except:
            raise 'InvalidObject'
        
        self.f = f
        
    def Analyze(self):
        pass
    
    def Normalize(self):
        pass
    
    def WriteData(self):
        pass


if __name__ == "__main__":
    
    analyzer = Analyzer('single')
    
    books = listdir('../books')
    
    for book in books:
        try:
            b = open('../books/' + book,'r')
        except:
            print '[ERROR] Unable to open book'
            pass
        
        try:
            analyzer.GiveFile(b)
        except:
            print '[ERROR] While giving file into analyzer'
        
        
    
    exit(0)